package perss.lance.jmsdemo;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

import javax.jms.*;

public class QueueProducerTest {
    public static void main(String[] args) throws JMSException {
        ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        Destination queue = new ActiveMQQueue("lance.queue");
        Connection con = factory.createConnection();
        con.start();
        Session sen = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = sen.createProducer(queue);
        TextMessage msg = sen.createTextMessage("I am Lance!");
        producer.send(msg);
        producer.close();
        con.close();
    }
}
